package com.xdja.practice;

import org.junit.Test;

/**
 * @author mob-wan
 * @date 2020/7/13
 * <p>
 * 递归--兔子问题
 */
public class Rabbit {

    @Test
    public void testRabbit() {
        rabbitNumber(12, 0, 0, 2);
    }

    /**
     * @param time           时长，单位：月
     * @param bigRabbitNum   可以生小兔子的大兔子的数量
     * @param smallRabbitNum 小兔子
     * @param birthRabbitNum 刚出生的小兔子
     **/
    public void rabbitNumber(int time, int bigRabbitNum, int smallRabbitNum, int birthRabbitNum) {
        bigRabbitNum = bigRabbitNum + smallRabbitNum;
        smallRabbitNum = birthRabbitNum;
        birthRabbitNum = bigRabbitNum;
        time--;
        if (time == 1) {
            int number = bigRabbitNum + smallRabbitNum + birthRabbitNum;
            System.out.println(number);
            return;
        }
        rabbitNumber(time, bigRabbitNum, smallRabbitNum, birthRabbitNum);
    }
}
